package com.pdd.service.Impl;

import com.pdd.beans.OrderDetail;
import com.pdd.dao.OrderDetailMapper;
import com.pdd.service.OrderDetailService;
import lombok.Setter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @创建时间: 2018/8/15 - 14:40
 * @编写人员: 丷教皇
 * @文件描述:
 */
@Service
public class OrderDetailServiceImpl implements OrderDetailService {

    @Autowired
    @Setter
    private OrderDetailMapper orderDetailMapper;

    /**
     * 新增详情
     *
     * @param orderDetail 详情对象
     * @return 返回成功失败
     */
    public boolean addOrderDetail(OrderDetail orderDetail) {
        return orderDetailMapper.insertOrderDetail(orderDetail) > 0;
    }

    /**
     * 按编号删除详情
     *
     * @param id 详情编号
     * @return 返回成功失败
     */
    public boolean delOrderDetail(int id) {
        return orderDetailMapper.deleteOrderDetail(id) > 0;
    }

    /**
     * 更新详情
     *
     * @param orderDetail 详情对象
     * @return 返回成功失败
     */
    public boolean updOrderDetail(OrderDetail orderDetail) {
        return orderDetailMapper.updateOrderDetail(orderDetail) > 0;
    }

    /**
     * 按编号查询详情
     *
     * @param id 详情编号
     * @return 返回结果
     */
    public OrderDetail getById(int id) {
        return orderDetailMapper.selectById(id);
    }

    /**
     * 查询所有详情
     *
     * @return 返回结果
     */
    public List<OrderDetail> getAll() {
        return orderDetailMapper.selectAll();
    }
}
